﻿using System;
using System.Threading;

namespace Client
{
    public class EchoClient
    {
        private ConnectToServer connectToServer;
        private Boolean aktiv=true;

        public EchoClient(String serverIp, Int32 port)
        {
            
            connectToServer = new ConnectToServer(serverIp, port);
            Thread temp = new Thread(ConnectToServer.ReciveMessage);
            temp.Start();
            ReadInput();
            
            connectToServer.Dispose();
            connectToServer = null;
            
            
        }

        public void ReadInput()
        {
            while (aktiv)
            {
                String command = Console.ReadLine();

                if (command == "luk")
                    aktiv = false;
                else
                {
                    connectToServer.SendMessage(command);
                    
                }
                
            }
        }
    }
}